package ArrayListTest.homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(11,2));
        list.add(new Point(3,41));
        list.add(new Point(51,6));
        list.add(new Point(7,81));
        System.out.println("list原始数据："+list);//list原始数据：[(11,2), (3,41), (51,6), (7,81)]


        Collections.sort(list,(o1,o2)->o1.getX()-o2.getX());

        /*
        Collections.sort(list, new Comparator<Point>() {
            @Override
            public int compare(Point o1, Point o2) {
                return o1.getX()-o2.getX();
                //return o2.getX()-o1.getX();
                //return o2.getY()-o1.getY);
                //return o1.getY()-o2.getY);
            }
        });
         */
        System.out.println("list原始数据："+list);//list原始数据：[(3,41), (7,81), (11,2), (51,6)]
    }
}
